package com.hermit.qmst.request;
import android.content.Context;
import android.os.AsyncTask;

public class RequestTask extends AsyncTask<String, Integer, String>{
	
	private Context mContext;
	private String mUrl;
	private RequestTaskInterface mTaskObserver;
	private String requestType;
	private String postContent;
	
	public RequestTask(RequestTaskInterface pRequestTaskInterface,String pUrl,String pSendParam,String pRequestType,Context pContext){
		mContext = pContext;
		mUrl = pUrl;
		mTaskObserver = pRequestTaskInterface;
		requestType = pRequestType;
		postContent = pSendParam;
	}
	
	@Override
	protected String doInBackground(String... params) {
		
		if (requestType.equals("POST")) {
			HttpEngine _HttpEngine = new HttpEngine(requestType, mUrl, postContent);
			String _Retrun =_HttpEngine.requestPost();
			return _Retrun;
		}else if(requestType.equals("GET")){
			HttpEngine _HttpEngine = new HttpEngine(requestType, mUrl, postContent);
			String _Retrun =_HttpEngine.requestGet();
			return _Retrun;
		}
		
		return "";
	}

	@Override
	protected void onPostExecute(String result) {
		//super.onPostExecute(result);
		mTaskObserver.postExecute(result);
	}

}
